{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "generic-dayton",
   "metadata": {},
   "source": [
    "https://leetcode.com/problems/stone-game/\n",
    "\n",
    "\n",
    "Time Limit Exceeded\n",
    "\n",
    "\n",
    "\n",
    "```python\n",
    "class Solution:\n",
    "    def stoneGame(self, piles: List[int]) -> bool:\n",
    "        #5:21\n",
    "        return self.next(piles, 1, 0, 0)\n",
    "        #5:27\n",
    "    def next(self, piles, who, alex, lee):\n",
    "        #1 is alex\n",
    "        #2 is Lee\n",
    "        if len(piles) == 0:\n",
    "            if alex > lee:\n",
    "                return True\n",
    "            else:\n",
    "                return False\n",
    "        if who == 1:\n",
    "            return self.next(piles[1:], 2, alex+piles[0], lee) or \\\n",
    "            self.next(piles[:-1], 2, alex+piles[-1], lee)\n",
    "        else:\n",
    "            return self.next(piles[1:], 1, alex, lee+piles[0]) or \\\n",
    "            self.next(piles[:-1], 1, alex, lee+piles[-1])\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "industrial-cornwall",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
